<?
layout("/inc/win_layout.html",{title:sysTitle}){
    ?>
 <div class="page-content">
      
        <div style="padding-bottom: 50px;">
			<button style="float: right; margin-bottom : 10px;" class="btn btn-sm btn-primary" onclick="addEditGeneralWordCategory('0')">新增</button>	
				
		</div>
		<div style="height: 400px;overflow :auto;">
			<table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
				<thead>
					<tr>
						<th width="8%">序号</th>
						<th>分类名称</th>
						<th>分类号</th>
						<th width="20%">操作</th>
					</tr>
				</thead>
				<tbody id="findGeneralWordCategory"></tbody>
			</table>
		</div>
	</div>
<?} ?>

<script>
	function WordList(){
		var index = parent.layer.getFrameIndex(window.name);
		window.parent.generalWordList();
		parent.layer.msg('关闭成功');
		parent.layer.close(index);
	}
	var id;
	$(function() {
		demo1(1);
	});
	function getaddupate() {
		return id;
	}
	function addEditGeneralWordCategory(lid) {
		id = lid;
		layer.open({
		 	type : 2,
		 	title : '分类新增编辑',
			area : [ '400px', '335px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["word-generalWordCategory-addEdit.html",'no'],
			yes: function(index,layer){
					var iframeWin = window.parent.window[window.name].window['layui-layer-iframe'+index];
	                iframeWin.Page();
  	        },
			cancel : function(index) {
				
			}
		});
	}
	function del(id) {
		if (confirm("是否确认删除！！"))
		{
			$.ajax({
				type : "post",
				url : "./delgeneralWordCategory.do",
				data : {
					"id" : id
				},
				dataType : "json",
				success : function(data) {
					if(data.count<1){
						layer.msg('删除成功');
						 window.parent.demo1();
						 demo1();
					}else{
						layer.msg('删除失败,与其它表关联不可删除！');
					}
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
	}
	function demo1() {
			$.getJSON(
						"./findAllGeneralWordCategory.do",
						function(res) {
							//此处仅仅是为了演示变化的内容
							var str = "";
							$("#findGeneralWordCategory").html("");
							for ( var i = 0; i <  res[0].size; i++) {
								str += "<tr>"
										+"<td>"+ (i + 1)+ "</td>"
										+"<td> <label>"+ res[i].categoryName + "</label></td>"
										+"<td><label >"+ res[i].categorySid + "</label></td>"
										+"<td>"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"del('"+ res[i].id+ "')\">删除</button>&nbsp;&nbsp;"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"addEditGeneralWordCategory('"+ res[i].id+ "')\">编辑</button>" 
										+ "</td></tr>";
							}
							$("#findGeneralWordCategory").append(str);
						});
	};

</script>